using System;
using System.Data;
using System.Collections.Generic;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for Floor
/// </summary>
public class Floor
{
    #region Fields
    decimal _proID;
    string _proName;
    string _proImg;
    string _tinyDes;
    string _fullDes;
    decimal _startingPrice;
    bool _hasFloorPrice;
    decimal _floorPrice;
    bool _quick;
    decimal _quickPrice;
    decimal _bidGap;
    string _proPlace;
    DateTime _bd;
    DateTime _efd;
    bool _returnable;
    int _returnPeriod;
    string _rpt;
    decimal _tax;
    string _places;
    string _seller;
    decimal _curBid;
    int _buyers;
    int _bids;
    DateTime _fd;
    bool _ebQP;
    decimal _catID;
    bool _isDone;

    List<PaymentDetail> _payterms;
    List<TransportCharge> _charges;
    #endregion

    #region Properties
    public decimal ProID
    {
        get { return _proID; }
        set { _proID = value; }
    }

    public string ProName
    {
        get { return _proName; }
        set { _proName = value; }
    }

    public string ProImg
    {
        get { return _proImg; }
        set { _proImg = value; }
    }

    public string TinyDes
    {
        get { return _tinyDes; }
        set { _tinyDes = value; }
    }

    public string FullDes
    {
        get { return _fullDes; }
        set { _fullDes = value; }
    }

    public decimal StartingPrice
    {
        get { return _startingPrice; }
        set { _startingPrice = value; }
    }

    public bool HasFloorPrice
    {
        get { return _hasFloorPrice; }
        set { _hasFloorPrice = value; }
    }

    public decimal FloorPrice
    {
        get { return _floorPrice; }
        set { _floorPrice = value; }
    }

    public bool Quick
    {
        get { return _quick; }
        set { _quick = value; }
    }

    public decimal QuickPrice
    {
        get { return _quickPrice; }
        set { _quickPrice = value; }
    }

    public decimal BidGap
    {
        get { return _bidGap; }
        set { _bidGap = value; }
    }

    public string ProPlace
    {
        get { return _proPlace; }
        set { _proPlace = value; }
    }

    public DateTime Bd
    {
        get { return _bd; }
        set { _bd = value; }
    }

    public DateTime Efd
    {
        get { return _efd; }
        set { _efd = value; }
    }

    public bool Returnable
    {
        get { return _returnable; }
        set { _returnable = value; }
    }

    public int ReturnPeriod
    {
        get { return _returnPeriod; }
        set { _returnPeriod = value; }
    }

    public string Rpt
    {
        get { return _rpt; }
        set { _rpt = value; }
    }

    public decimal Tax
    {
        get { return _tax; }
        set { _tax = value; }
    }

    public string Places
    {
        get { return _places; }
        set { _places = value; }
    }

    public string Seller
    {
        get { return _seller; }
        set { _seller = value; }
    }

    public decimal CurBid
    {
        get { return _curBid; }
        set { _curBid = value; }
    }

    public int Buyers
    {
        get { return _buyers; }
        set { _buyers = value; }
    }

    public int Bids
    {
        get { return _bids; }
        set { _bids = value; }
    }

    public DateTime Fd
    {
        get { return _fd; }
        set { _fd = value; }
    }

    public bool EbQP
    {
        get { return _ebQP; }
        set { _ebQP = value; }
    }

    public decimal CatID
    {
        get { return _catID; }
        set { _catID = value; }
    }

    public bool IsDone
    {
        get { return _isDone; }
        set { _isDone = value; }
    }

    public List<PaymentDetail> Payterms
    {
        get { return _payterms; }
        set { _payterms = value; }
    }

    public List<TransportCharge> Charges
    {
        get { return _charges; }
        set { _charges = value; }
    }
    #endregion

    public Floor() { }

    public Floor(decimal proID, string proName, string proImg, string tinyDes, string fullDes,
        decimal startingPrice, bool hasFloorPrice, decimal floorPrice, bool quick,
        decimal quickPrice, decimal bidGap, string proPlace, DateTime bd, DateTime efd,
        bool returnable, int returnPeriod, string rpt, decimal tax, string places,
        string seller, decimal curBid, int buyers, int bids, DateTime fd, bool ebQP,
        decimal catID, bool isDone)
    {
        _proID = proID;
        _proName = proName;
        _proImg = proImg;
        _tinyDes = tinyDes;
        _fullDes = fullDes;
        _startingPrice = startingPrice;
        _hasFloorPrice = hasFloorPrice;
        _floorPrice = floorPrice;
        _quick = quick;
        _quickPrice = quickPrice;
        _bidGap = bidGap;
        _proPlace = proPlace;
        _bd = bd;
        _efd = efd;
        _returnable = returnable;
        _returnPeriod = returnPeriod;
        _rpt = rpt;
        _tax = tax;
        _places = places;
        _seller = seller;
        _curBid = curBid;
        _buyers = buyers;
        _bids = bids;
        _fd = fd;
        _ebQP = ebQP;
        _catID = catID;
        _isDone = isDone;
    }

    public Floor(DataRow row)
    {
        _proID = Convert.ToDecimal(row["ProID"]);
        _proName = row["ProName"].ToString();
        _proImg = "~/imgs/floors/" + _proID.ToString() + "/main.jpg";
        _tinyDes = row["TinyDes"].ToString();
        _fullDes = row["FullDes"].ToString();
        _startingPrice = Convert.ToDecimal(row["StartingPrice"]);
        _hasFloorPrice = Convert.ToBoolean(row["HasFloorPrice"]);
        _floorPrice = Convert.ToDecimal(row["FloorPrice"]);
        _quick = Convert.ToBoolean(row["Quick"]);
        _quickPrice = Convert.ToDecimal(row["QuickPrice"]);
        _bidGap = Convert.ToDecimal(row["BidGap"]);
        _proPlace = row["ProPlace"].ToString();
        _bd = Convert.ToDateTime(row["BD"]);
        _efd = Convert.ToDateTime(row["EFD"]);
        _returnable = Convert.ToBoolean(row["Returnable"]);
        _returnPeriod = Convert.ToInt32(row["ReturnPeriod"]);
        _rpt = row["RPT"].ToString();
        _tax = Convert.ToDecimal(row["Tax"]);
        _places = row["Places"].ToString();
        _seller = row["Seller"].ToString();
        _curBid = Convert.ToDecimal(row["CurBid"]);
        _buyers = Convert.ToInt32(row["Buyers"]);
        _bids = Convert.ToInt32(row["Bids"]);
        _fd = Utils.GetDateTime(row["FD"]);
        _ebQP = Convert.ToBoolean(row["EbQP"]);
        _catID = Convert.ToDecimal(row["CatID"]);
        _isDone = Convert.ToBoolean(row["IsDone"]);
    }

    /// <summary>
    /// Update ProID field for 2 lists (_payterms, charges)
    /// </summary>
    public void UpdateDetailsInfo()
    {
        foreach (PaymentDetail payterm in _payterms)
        {
            payterm.ProID = _proID;
        }

        foreach (TransportCharge charge in _charges)
        {
            charge.ProID = _proID;
        }
    }
}
